﻿using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Liquid;
using Zeus.Classes.Documents;

namespace Zeus.Classes.Engines.Scripting_Engine
{
    public partial class EditorText : UserControl
    {
        private TextDocument TextDoc;
        public EditorText(Document Doc)
        {
            InitializeComponent();
            TextDoc = (TextDocument) Doc;
            ContentDoc.Text = TextDoc.ReadFile();
            
        }
        
        public EditorText()
        {
            InitializeComponent();
        }

        private void SaveText_Click(object sender, RoutedEventArgs e)
        {
            string Content = ContentDoc.Save(Format.Text, RichTextSaveOptions.None);
            TextDoc.Save(Content);
        }

        private void ContentDoc_CursorMoved(object sender, RichTextBoxEventArgs e)
        {
            this._LineNumber.Text = this.ContentDoc.LineNumber.ToString();
        }

        private int test = 0;
        private void ContentDoc_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (test==1)
            {
                TextDoc.IsChanged = true;
                TextDoc.NotifyChanged();
            }
            else
            {
                test = 1;
            }
        }
    }
}
